package com.itsm.service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itsm.entity.ProcessApprove;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface ProcessApproveMapper extends BaseMapper<ProcessApprove> {
    @Select("select p.process_no,p.subject ,p.content ,p.state ,p.score ,p.is_accepted ,a.step ,a.status,a.approver  from process p left join approve a on p.process_no = a.process_no " +
            " and a.id = (select max(id) from approve a2 where p.process_no = a2.process_no and a2.sub_time  is not null group by a2.process_no) " +
            "where p.create_name = #{name} and p.is_delete =1 order by p.process_no desc")
    List<ProcessApprove> getAll(String name);

    @Select("select p.process_no,p.subject ,p.content ,p.state ,p.score ,p.is_accepted ,a.step ,a.status ,p.create_name from process p left join approve a on p.process_no = a.process_no " +
            " and a.count = (select max(count) from approve a2 where p.process_no = a2.process_no) " +
            "where approver = #{name} and p.is_delete =1 order by p.process_no desc")
    List<ProcessApprove> getAllApp(String name);

}
